#!/usr/bin/env python
#from mpi4py import MPI
import random, math
import numpy as np
import util
import pickle
import sys

A = "Andreas"

for i in range(4) :
	input = 1000000 * int(math.pow(2,i))
	for j in range(5) :
		skew = 1.5 + (j*0.25)
		with util.Timer() as t :
			zipfdist = list(np.random.zipf(skew, input))
		print t.interval


		a = []
		with util.Timer() as t :
			random_samples = np.random.random_sample((input,))
		print t.interval

		with util.Timer() as t :
			a = zip(list(map(lambda i : int(i), zipfdist)), random_samples)
#			for i,el in enumerate(zipfdist) :
#				a.append(("".join(["a",str(el)]), random_samples[i]))

		print t.interval

		dir = "./"
		filename = dir +"_".join(["zipf",str(input),str(skew)]) + ".in"
		f = open(filename,'w')
#
		for entry in a :
			#print entry
			f.write("{0:d}\t{1:f}\n".format(entry[0],entry[1]))
		f.close()
##		np.save(filename,  np.array(a, dtype='float64'))
#
#		with util.Timer() as t :
#			f = open(filename,'w')
#			pickle.dump(a, f)
#			f.close()
#		print t.interval